<!--
 * @Author: dengyl
 * @Date: 2022-01-18 14:08:49
 * @LastEditTime: 2022-08-19 16:55:30
 * @LastEditors: 代琪 1529992814@qq.com
 * @Description: 新闻-标题摘要
 * @FilePath: \code\ctp-static-portal-front\src\components\news\components\abstract.vue
-->
<template>
  <div class="abstract" :style="`background-color: ${options.backgroundColor}`">
    <ul ref="$ulDom">
      <li v-for="item in list.slice(0, +options.count)" :key="item.id">
        <div class="pic">
          <a :href="item.src" target="_blank">
            <ShowImg :item="item" />
          </a>
        </div>
        <div :style="`width:${contentWidth - 300}px`" class="info-pane">
          <div class="title">
            <!--标记-->
            <template v-if="item.extText">
              <template v-for="(ext, i) in item.extText">
                <Tag :key="i" :value="ext[0]" />
              </template>
            </template>
            <a :href="`${newsBasePath}${item.link}`" target="_blank">{{ item.subject }}</a>
          </div>
          <div class="detail">{{ item.brief }}</div>
          <div class="info">
            <span v-if="options.rowList.includes('publishDate')"
              ><span>{{ item.createDate }}</span></span
            >
            <!-- <span>阅读量：{{ item.viewNum }}</span> -->
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
  import Tag from './tag.vue';

  export default {
    name: 'Abstract',
    components: {
      Tag
    },
    props: {
      list: { type: Array },
      options: { type: Object },
      contentWidth: {
        type: Number,
        default: 0
      }
    },
    data() {
      return {
        newsBasePath: `${_basePath}/`
      };
    }
    // methods: {
    //   textOverflow(str) {
    //     if (!str) return '';
    //     return str.length > 30 ? `${str.substring(0, 30)}...` : str;
    //   },
    // },
  };
</script>
<style lang="scss" scoped>
  .abstract {
    > ul {
      padding: 0;
      margin: 0;
      list-style: none;

      > li {
        height: 140px;
        margin-bottom: 10px;

        > div {
          display: inline-block;
          vertical-align: top;
        }

        > .pic {
          > a {
            display: block;
            width: 210px;
            height: 130px;

            > img {
              width: 100%;
              height: 100%;
              border-radius: 4px;
            }
          }
        }

        > .info-pane {
          position: relative;
          height: 100%;
          margin-left: 10px;
          border-bottom: 1px solid #fff;

          > .title {
            display: block;
            width: 100%;
            overflow: hidden;
            font-size: 16px;
            font-weight: bold;
            color: #333;
            text-overflow: ellipsis;
            word-break: keep-all;
            white-space: nowrap;

            > div {
              display: inline-block;
            }
          }

          > .detail {
            display: -webkit-box;
            max-height: 32px;
            margin-top: 10px;
            overflow: hidden;
            font-size: 12px;
            line-height: 16px;
            color: #999;
            text-overflow: ellipsis;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
          }

          > .info {
            position: absolute;
            bottom: 0;
            padding: 10px 0;
            font-size: 12px;
            color: #999;

            > span {
              margin-right: 20px;
            }
          }
        }
      }
    }
  }
</style>
